<?

$specId = $_POST['specId'];
$specId = 1;
$encodedPNGData = $_POST['encodedPNGData'];
$percent = 0.5;

if (isset($_POST['encodedPNGData'])){

	$binaryData = base64_decode($encodedPNGData);
	$file = "../media/specImages/".$specId.".png";
	file_put_contents($file, $binaryData);
	

	// Get new sizes
	list($width, $height) = getimagesize($file);
	$newwidth = $width * $percent;
	$newheight = $height * $percent;

	// Load
	$thumb = imagecreatetruecolor($newwidth, $newheight);
	$source = imagecreatefrompng($file);

	// Resize
	imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

	// Output
	imagejpeg($thumb, "../media/specImages/".$specId."_small.png");
	
}
echo "<result><success></success></result>";

?>